package com.gitee.mapper;

import com.gitee.annotation.AutoFill;
import com.gitee.annotation.DefaultValue;
import com.gitee.entity.FriendUpdates;
import com.gitee.enumeration.OperationType;
import com.gitee.vo.FriendUpdatesVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FriendUpdatesMapper {

    /**
     * 分页查询
     */
    List<FriendUpdatesVO> pageQuery(@Param("start") Integer start, @Param("end") Integer end, @Param("userIdList") List<Integer> userIdList);

    /**
     * 新增动态
     */
    @Insert("insert into sxq_friend_updates values(null,#{img},#{title},#{styleTitle},#{content},#{styleContent},#{hitsCount},#{likeCount},#{commentCount},#{collectCount},#{shareCount},#{userId},#{createTime},#{updateTime})")
    @AutoFill(OperationType.INSERT)
    @DefaultValue(excludeKey = {"id"})
    void insert(FriendUpdates friendUpdates);

    Long count(List<Integer> userIdList);

    @AutoFill(OperationType.UPDATE)
    void updateById(FriendUpdates friendUpdates);

    List<FriendUpdatesVO> selectByTitle(String title);

    FriendUpdatesVO selectById(Integer id);

    List<FriendUpdatesVO> selectByUserId(Integer userId);

    List<FriendUpdatesVO> selectByIds(List<Integer> ids);

    @Select("select like_count from sxq_friend_updates where user_id = #{userId}")
    List<Long> countUserLike(Integer userId);

    @Delete("delete from sxq_friend_updates where id = #{friendUpdateId}")
    void deleteById(Integer friendUpdateId);
}
